<template>
  <a-card :bordered="false">
    <a-result status="success" :title="'项目发布成功'" :sub-title="'项目发布成功，您可前往邀请人员加入您的项目'">
      <template #extra>
        <!-- <a-button type="primary">邀请人员</a-button> -->
        <a-upload
          style="margin-right: 20px; display: inline-block"
          :before-upload="beforeUpload"
          @change="handleChange"
          :fileList="[]"
        >
          <a-button type="primary"> <a-icon type="upload" />邀请人员</a-button>
        </a-upload>
        <a-button style="margin-left: 8px" @click="() => $router.go(-1)">创建新项目</a-button>
        <a-button style="margin-left: 8px" @click="goProjectList">返回项目管理</a-button>
      </template>
      <div class="content">
        <a-row style="margin-bottom: 16px">
          <a-col :xs="24" :sm="8" >
          </a-col>
          <a-col :xs="24" :sm="16" >
            <a-descriptions>
                <a-descriptions-item label="项目名称" :span="3">{{project.projectName}}</a-descriptions-item>
                <!-- <a-descriptions-item label="合同金额" :span="3">{{project.cost}}</a-descriptions-item> -->
                <a-descriptions-item label="所属客户" :span="3">{{project.customerName}}</a-descriptions-item>
                <a-descriptions-item label="所属公司" :span="3">{{project.companyName}}</a-descriptions-item>
                <!-- <a-descriptions-item label="个人签署合同" :span="3">{{project.contractName}}</a-descriptions-item> -->
            </a-descriptions>
          </a-col>
        </a-row>
      </div>
    </a-result>
  </a-card>
</template>

<script>
import { projectDetails , projectUserUpload } from '@/api/services/project';
import { fileUpload } from '@/api/system';
import { USER_TYPE } from '@/store/mutation-types';
import storage from 'store';
export default {
  name: 'Success',
  data () {
    return {
      projectId: '',
      project:  {
        projectName: '',
        cost: '',
        customerName: '',
        companyName: '',
        contractName: '',
      },
    }
  },
  created(){
    this.projectId = this.$route.query.projectId;
    this.getDetail();
  },
  methods: {
    getDetail(){
      let _this = this
      projectDetails(_this.projectId)
      .then(res=>{
        if(res.success){
          _this.project = JSON.parse(JSON.stringify(res.data))
        }else{
          _this.$notification['error']({
            message: '温馨提示',
            description: res.errMessage,
            duration: 8
          })
        }
      })
    },
    goProjectList(){
      var userType = sessionStorage.getItem(USER_TYPE);
      var paths = userType == 2 ? '/servicesProjects/projectsList' : '/companysProjects/projectsList'
      this.$router.push({path: paths})
    },
    beforeUpload(file) {
            return false;
        },
        handleChange({file,fileList}){
            console.log(file,'fiel')
            let _this = this
            const formData = new FormData();
            formData.append('file',file)
            formData.append('projectId',_this.projectId)
            projectUserUpload(formData)
            .then(res=>{
                if(res.success){
                    console.log(res,'res')
                    _this.$router.push({path: '/servicesProjects/userExcelUpload', query: { 'fileData': JSON.stringify(res.data), 'projectId': _this.projectId}})
                }else{
                    _this.$notification['error']({
                        message: '温馨提示',
                        description: res.errMessage,
                        duration: 8
                    })
                }
            })
        },
  },
}
</script>
